#include <iostream>
#include <stack>
#include <unordered_map>

bool is_valid_bracket_sequence(const std::string& sequence) {
    std::stack<char> stack;
    std::unordered_map<char, char> mapping = {{')', '('}, {']', '['}, {'}', '{'}, {'>', '<'}};
    for (char bracket : sequence) {
        if (mapping.find(bracket) == mapping.end()) {
            stack.push(bracket);
        } else {
            if (stack.empty() || mapping[bracket] != stack.top()) {
                return false;
            }
            stack.pop();
        }
    }
    return stack.empty();
}

int main() {
    std::string input_sequence;
    std::cin >> input_sequence;
    if (is_valid_bracket_sequence(input_sequence)) {
        std::cout << "True" << std::endl;
    } else {
        std::cout << "False" << std::endl;
    }
    return 0;
}